﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace K2AlgoExtensions
{

    public class PublisherFactory : KaiTrade.Interfaces.K2InstanceFactory
    {
        /// <summary>
        /// Singleton 
        /// </summary>
        private static volatile PublisherFactory s_instance;

        /// <summary>
        /// used to lock the class during instantiation
        /// </summary>
        private static object s_Token = new object();

        private List<string> m_Names;

        /// <summary>
        /// Logger
        /// </summary>
        public log4net.ILog m_Log = log4net.LogManager.GetLogger("Kaitrade");



        public static PublisherFactory Instance()
        {
            // Uses "Lazy initialization" and double-checked locking
            if (s_instance == null)
            {
                lock (s_Token)
                {
                    if (s_instance == null)
                    {
                        s_instance = new PublisherFactory();
                    }
                }
            }
            return s_instance;
        }

        protected PublisherFactory()
        {
            m_Names = new List<string>();
            
            m_Names.Add("K2BareBonesPub");


        }


        public object CreateInstance(string name)
        {
            object myObject = null;
            switch (name)
            {
                
                case "K2BareBonesPub":
                    myObject = new K2BareBonesPub();
                    break;


                default:
                    break;
            }
            return myObject;
        }

        public List<string> Names
        {
            get { return m_Names; }
        }
    }
}
